// 插件/模板市场
import { ref, watch } from 'vue'
import { stores as mockStore } from '@/mock/store'
export interface Store {
  id: Number
  name: String
  des: String
  status: Number
  remark?: String
}
export interface Filter {
  keywords?:Number
  category?:String
  status?:Number
  type:String
  page: Number
  size: Number
}
export const comStore = () => {
  const init:Array<Store> = []
  const stores = ref(init)
  const filtersInit:Filter = {
    type: 'plugin',
    page: 1,
    size: 10
  }
  const filters = ref(filtersInit)
  const getStores = () => {
    stores.value = mockStore
  }
  /**
   * 详情
   * @param id
   */
  const detail = (id:Number) => {
    console.log(`id:${id}`)
  }
  const changeStus = (event:any) => {
    console.log('event:', event)
  }
  watch(() => filters.value, (oldValue, newValue) => {
    console.log('request api:', filters.value)
  }, { deep: true })
  return {
    stores,
    getStores,
    detail,
    changeStus,
    filters
  }
}
